package com.eling.elcms.travel.webapp.controller;

import com.eling.elcms.basedoc.model.ContactAddress;
import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.core.webapp.spring.ModelFilling;
import com.eling.elcms.member.model.Member;
import com.eling.elcms.travel.model.CertificatesTransfer;
import com.eling.elcms.travel.model.view.CertificateTransferView;
import com.eling.elcms.travel.service.ICertificatesTransferManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@Controller
public class CertificatesTransferController extends BaseFormController {
	
	@Autowired
	private ICertificatesTransferManager certificatesTransferManager;
	
	@RequestMapping("/api/certificatestransfer/save")
    @ResponseBody
	public CertificatesTransfer save(@ModelAttribute@ModelFilling CertificatesTransfer cond){
		return certificatesTransferManager.save(cond);
	}
	
	@RequestMapping("/api/certificatestransfer/{pkCertificatesTransfer}/delete")
	@ResponseBody
	public Msg delete(@PathVariable Long pkCertificatesTransfer){
		certificatesTransferManager.remove(pkCertificatesTransfer);
		return new Msg("删除成功");
	}
	
	@RequestMapping("/api/certificatestransfer/query")
    @ResponseBody
	public List<CertificatesTransfer> query(@ModelAttribute CertificatesTransfer cond){
		return certificatesTransferManager.query(cond);
	}
	
	
	@RequestMapping("/api/certificatestransfer/search*")
	@ResponseBody
	public List<CertificatesTransfer> search(@ModelAttribute SearchCondition sc,@ModelAttribute CertificatesTransfer cond){
		sc.setQueryCondition(cond);
		return certificatesTransferManager.search(sc);
	}
	
	@RequestMapping("/api/certificatestransfer/queryNotes")
	@ResponseBody
	public List<CertificateTransferView> queryNotes(@RequestParam(value="operateDate")Date operateDate,
											   @RequestParam(value="operateDateEnd")Date operateDateEnd){
		return certificatesTransferManager.queryNotes(operateDate,operateDateEnd);
		
	}
	
	
	@RequestMapping("/api/certificatestransfer/queryNotess")
	@ResponseBody
	public List<CertificateTransferView> queryNotess(@RequestParam(value="operateDate")Date operateDate,
			   									   @RequestParam(value="operateDateEnd")Date operateDateEnd,
			   									   @RequestParam(value="pkCertificatesTransfer") Long pkCertificatesTransfer){
		return certificatesTransferManager.queryNotess(operateDate,operateDateEnd,pkCertificatesTransfer);
	}
	
	
	@RequestMapping("/api/certificatestransfer/saveall")
    @ResponseBody
	public CertificatesTransfer saveAll(@ModelAttribute CertificatesTransfer cond,@ModelAttribute ContactAddress contactAddress){
		return certificatesTransferManager.saveAll(cond,contactAddress);
	}
	
	
	@RequestMapping("/api/certificatestransfer/searchmember")
	@ResponseBody
	public List<Member> searchMember(@ModelAttribute SearchCondition sc,@ModelAttribute Member cond){
		sc.setQueryCondition(cond);
		return certificatesTransferManager.searchMember(sc);
	}
}
